﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_ApproveDocument]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_ApproveDocument];
GO
CREATE PROCEDURE [dbo].[sproc_ApproveDocument]
        @DocIDs nvarchar(3000),
        @Approver nvarchar(300)
/*
=====================================================
功能:    审批文档
参数:
    @DocIDs    待审批文档的ID集合,用逗号分割
    @Approver    审批人
=====================================================
*/
AS

DECLARE @SQL nvarchar(4000)

--//写动态SQL语句
SET @SQL = 'UPDATE uds_document SET DocApproved =1,DocApprover =''' + @Approver + ''',DocApproveDate=getdate(),DocViewedTimes=0 WHERE docid in (' + @DocIDs + ')'
--//执行动态SQL语句
EXEC (@SQL)
RETURN 1